import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;

public class ShTimer extends TimerTask {

	static SimpleDateFormat hm = new SimpleDateFormat("HHmm");

	@Override
	public void run() {
		System.out.println(new Date()+"...");
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		if(args.length==0){
			System.out.println("# Usage: ShTimer mmss");
			return;
		}
		
		Timer tm = new Timer();
		ShTimer st = new ShTimer();
		tm.schedule(st, 0, 60000);
		String strHm = null;
		String exeTime = args.length==0?"0000":args[0];
		try {
			System.out.println("# execute time: "+exeTime);
			while (args.length > 0) {
				
				Date time = new Date();
				strHm = hm.format(time);
				Integer intHhmm = Integer.parseInt(strHm);
				Integer intArgHhmm = Integer.parseInt(exeTime);
				if (intHhmm >= intArgHhmm) {
					break;
				}

				Thread.sleep(3000);
			}
			tm.cancel();
			System.out.println("#  time up now: "+exeTime);
			

		} catch (InterruptedException e) {
			e.printStackTrace();
		}

	}

}
